package oop.ex2.tools;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * File name: ReadTextFile.java
 * @Author: Guy Oren and Yossi Avital
 * Description: An object that gets the main commands file and makes it seperatable to lines. 
 */
public class ReadTextFile {
	private FileReader readFile;
	private File commandsFile;
	private BufferedReader bufferedFile;
	
	/**
	 * constructs an instance of lines reading.
	 * @param commandsFile- the path of the txt commands file
	 * @throws IOException
	 */
	public ReadTextFile (String commandsFile) throws IOException {
		this.commandsFile= new File (commandsFile);
		this.readFile = new FileReader (this.commandsFile);
		this.bufferedFile= new BufferedReader(this.readFile);
		
	}
	/**
	 * returns the next line from the text.
	 * @return the next line from the text.
	 * @throws IOException
	 */
	public String readLine () throws IOException {
		return this.bufferedFile.readLine();
	}
	/**
	 * Closes the buffer.
	 * @throws IOException
	 */
	public void close () throws IOException {
		this.bufferedFile.close();
	}
	
}
